package bishizhuanyong.深信服;

import java.util.Scanner;

public class Main {
    public static int minCount=Integer.MAX_VALUE;
    public static int x;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        x=sc.nextInt();
        int[] nums=new int[n];
        for (int i=0;i<nums.length;i++)
            nums[i]=sc.nextInt();
        int process = process(nums, 0);
        System.out.println(process);
    }

    public static int process(int[] nums,int index){
        if (index==nums.length-1){
            return 0;
        }
        int min_bound=nums[index]-x;
        int max_bount=nums[index]+x;

        int init=index==0?0:1;
        int res=Integer.MAX_VALUE;
        for (int t=min_bound;t<=max_bount;t++){
            boolean flag=true;
           for (int i=index;i<nums.length;i++){
               if (Math.abs(nums[i]-t)>x) {
                   flag=false;
                   res=Math.min(res,init+process(nums, i));
                   break;
               }
           }
           if (flag==true)
               return 0;
        }
        return res;
    }
}







/*

最小编辑距离      好的dp题目

public int minDistance (String a, String b) {
        // write code here
        int[][] dp=new int[a.length()+1][b.length()+1];
        for (int i=0;i<dp.length;i++)
            dp[i][0]=i;
        for (int j=0;j<dp[0].length;j++)
            dp[0][j]=j;
        for (int i=1;i<dp.length;i++){
            for (int j=1;j<dp[0].length;j++){
                if (a.charAt(i-1)==b.charAt(j-1))
                    dp[i][j]=Math.min(dp[i-1][j-1],Math.min(dp[i-1][j]+1,dp[i][j-1]+1));
                else
                    dp[i][j]=Math.min(dp[i-1][j-1]+1,Math.min(dp[i-1][j]+1,dp[i][j-1]+1));
            }
        }
        return dp[a.length()][b.length()];
    }
 */
